package com.huawei.appmarket.framework.widget;

import android.content.Context;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
import android.graphics.drawable.LayerDrawable;
import android.util.AttributeSet;
import android.view.View;
import androidx.appcompat.widget.AppCompatTextView;
import com.huawei.appgallery.foundation.ui.css.CSSRule;
import com.huawei.appgallery.foundation.ui.css.CSSViewProxy;
import com.huawei.appgallery.foundation.ui.css.RenderListener;
import com.huawei.appgallery.foundation.ui.css.adapter.CSSPropertyName;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSMonoColor;
import com.huawei.appgallery.foundation.ui.css.adapter.type.CSSValue;
import o.erq;
import o.ewm.e;

public class PromotionSignTextView extends AppCompatTextView implements RenderListener {
    public PromotionSignTextView(Context context) {
        super(context);
        ˋ(context);
    }

    public PromotionSignTextView(Context context, AttributeSet attributeSet) {
        super(context, attributeSet);
        ˋ(context);
    }

    public PromotionSignTextView(Context context, AttributeSet attributeSet, int i) {
        super(context, attributeSet, i);
        ˋ(context);
    }

    private void ˋ(Context context) {
        setBackground(context.getResources().getDrawable(e.ꜟ));
    }

    public boolean onRenderReady(CSSViewProxy cSSViewProxy) {
        CSSRule rule = cSSViewProxy.getRule();
        View view = cSSViewProxy.getView();
        if (rule.getStyleDeclaration() != null) {
            CSSValue propertyValue = rule.getStyleDeclaration().getPropertyValue(CSSPropertyName.FONT_COLOR);
            if (propertyValue != null && (propertyValue instanceof CSSMonoColor)) {
                CSSMonoColor cSSMonoColor = (CSSMonoColor) propertyValue;
                setTextStyle(view.getContext(), cSSMonoColor.getColor(), cSSMonoColor.getColor());
            }
        }
        return false;
    }

    public void setTextStyle(Context context, int i, int i2) {
        Drawable ˏ = ˏ(context, erq.ˊ(i, 0.5f));
        int ˊ = erq.ˊ(i2, 1.0f);
        if (ˏ != null) {
            setBackground(ˏ);
        }
        setTextColor(ˊ);
    }

    private Drawable ˏ(Context context, int i) {
        GradientDrawable gradientDrawable = (GradientDrawable) ((LayerDrawable) context.getResources().getDrawable(e.ᶥ)).findDrawableByLayerId(16908288);
        if (gradientDrawable == null) {
            return null;
        }
        gradientDrawable.setStroke(2, i);
        return gradientDrawable;
    }
}
